/**
 * 地图操作封装
 */
import * as mars3d from "mars3d";
import * as Cesium from "mars3d-cesium";
import { dayjs, ElMessage, ElLoading, ElMessageBox } from "element-plus";
import * as turf from "@turf/turf";
import { cloneDeep } from "lodash";
import WKT from "terraformer-wkt-parser";
import { nextTick } from "vue";
import { emitter } from "@/utils/events";

class mapUtil {
  mapInstance;
  measure;
  terrainClip;
  groupLayer;
  constructor(map) {
    if (map) this.mapInstance = map;
    else throw new Error("constructor参数不能为空！");

    this.groupLayer = new mars3d.layer.GroupLayer();
  }
  initialization() {
    this.mapInstance.flyHome();
    // this.loadRigs();
  }
  initView() {
    this.mapInstance.scene.globe.depthTestAgainstTerrain = false;
    this.graphicLayer.clear(true);
    if (this.terrainClip) this.mapInstance.removeThing(this.terrainClip, true);
  }

  clearAllLayers() {
    // this.graphicLayer.clear(true);
    this.groupLayer.eachLayer((layer) => {
      layer.clear(true);
    });
    if (this.terrainClip) this.mapInstance.removeThing(this.terrainClip, true);
  }
}

export default mapUtil;
